﻿using GodSystemDAL;
using GodSystemModel;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GodSystemBLL
{

    public class RolesBLL
    {
        private static RolesDAL rolesDAL = new RolesDAL();
        
        public List<RolesModel> GetRolesList()
        {
            List<RolesModel> roleData = new List<RolesModel>();
            MySqlDataReader roleList = rolesDAL.GetRole();
            if (roleList.HasRows)
            {
                while (roleList.Read())
                {
                    RolesModel r = new RolesModel();
                    r.Id = roleList.GetInt32(0);
                    r.RoleName = roleList.GetString(1);
                    r.Remark = roleList.GetString(2);
                    roleData.Add(r);
                }
            }
            return roleData;
;

        }

        public object GetRole(RolesModel roles)
        {
            return rolesDAL.GetRole(roles);
        }


        public int AddRole(RolesModel roles)
        {
            return rolesDAL.AddRole(roles);
        }


        public int UpdateRole(RolesModel roles, string name)
        {
            return rolesDAL.UpdateRole(roles, name);
        }
    }
}
